package FinalProject;
import java.net.*;

public class OmokServer {

	private ServerSocket server;

	private RoomManager rMan = new RoomManager(); // message sender

	public OmokServer() {
	}

	void startServer() { // start server.

		try {

			server = new ServerSocket(7777); //default socket

			System.out.println("Created Server Socket. Waiting for connection");

			while (true) {

				// get thread which connected from client
				Socket socket = server.accept();

				// create the thread and execute
				Omok_Thread ot = new Omok_Thread(socket, rMan);

				ot.start();

				// add thread to rMan
				rMan.add(ot);

				System.out.println("Number of connected users: " + rMan.size());

			}

		} catch (Exception e) {

			System.out.println(e);

		}

	}

	public static void main(String[] args) {

		OmokServer server = new OmokServer();

		server.startServer();

	}
}